window.keyMap=(function(){

var keyMap=',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0123456789,,,,,,,abcdefghijklmnopqrstuvwxyz,,,,,0123456789*+,-./,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;=,-./`,,,,,,,,,,,,,,,,,,,,,,,,,,[\]\''.replace(/([^,])/g,"$1,").split(',')
keyMap.up=',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)!@#$%^&*(,,,,,,,ABCDEFGHIJKLMNOPQRSTUVWXYZ,,,,,0123456789*+,-./,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:++<_>?~,,,,,,,,,,,,,,,,,,,,,,,,,,{|}"'.replace(/([^,])/g,"$1,").split(',');
keyMap.alias={8:'back',9:'tab',13:'enter',27:'esc',32:' ',33:'pup',34:'pdown',35:'end',36:'home',37:'left',38:'up',39:'right',40:'down',45:'insert',46:'del',108:'enter',112:'f1',123:'f12'};
for(let i in keyMap.alias) keyMap[i]=keyMap.alias[i];
for(let i=1;i<12;i++)   keyMap[111+i]='f'+i;

function time_add(aliasName){
                            if(keyMap.timer) clearInterval(keyMap.timer);
                            keyMap.timer=setTimeout(function(){        keyMap.joinKey="";},keyMap.config.joinTimeout)
                            //字符联入
                            keyMap.joinKey+=aliasName;                                
}
function get(event){
            let name="",a=[];
            if({16:"shift",17:"ctrl",18:"alt"}[event.keyCode]) return ;
            event.ctrlKey && a.push("ctrl");
            event.shiftKey && a.push("shift");
            event.altKey && a.push("alt");
            a.push(keyMap[event.keyCode]);
            if(a.length==2 && event.shiftKey && keyMap.up[event.keyCode]) a=[keyMap.up[event.keyCode]];
            name=a.join("+");
            if(a.length==1 && name) time_add(name);
            return name;
}

function stop(event){
    event.stopPropagation  && event.stopPropagation();
    try{event.keyCode = 0;}catch(e){}
    try{event.returnValue = false;}catch(e){}
    return false;
}

  keyMap.get=get;
  keyMap.stop=stop;
  keyMap.config={
      joinTimeout:5000
  };
  keyMap.joinKey='';   //合并key
  
  return keyMap;
})();

 /**
 export default {
         get,
         stop
 }
 
 */